package com.easylinkin.linkappapi.common.exceptions;

/***
 * 自定义业务层异常
 **/
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 6958499248468627021L;

    /**
     * 错误信息
     */
    private String errorMsg;
    /**
     * 错误码
     */
    private String errorCode;


    public BusinessException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BusinessException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
    }

    public BusinessException(ExceptionEnum exceptionEnum) {
        super(exceptionEnum.getErrorMsg());
        this.errorCode = exceptionEnum.getErrorCode();
        this.errorMsg = exceptionEnum.getErrorMsg();
    }

    public BusinessException(String errorCode, String errorMsg, Throwable throwable) {
        super(errorMsg, throwable);
        this.errorCode = errorCode;
    }

    public BusinessException(ExceptionEnum exceptionEnum, Throwable throwable) {
        super(exceptionEnum.getErrorMsg(), throwable);
        this.errorCode = exceptionEnum.getErrorCode();
    }

    public BusinessException(ExceptionEnum exceptionEnum, String errorMsg) {
        super(errorMsg);
        this.errorCode = exceptionEnum.getErrorCode();
    }

    public BusinessException(StandardException standardException) {
        super(standardException.getErrorMsg());
        this.errorCode = standardException.getErrorCode();
        this.errorMsg = standardException.getErrorMsg();
    }

    public BusinessException(StandardException standardException, Throwable throwable) {
        super(standardException.getErrorMsg(), throwable);
        this.errorCode = standardException.getErrorCode();
    }

    public BusinessException(StandardException standardException, String errorMsg) {
        super(errorMsg);
        this.errorCode = standardException.getErrorCode();
    }


    /**
     * 获取错误码
     *
     * @return property value of errorCode
     */
    public String getErrorCode() {
        return errorCode;
    }

    /**
     * 设置错误码
     *
     * @param errorCode value to be assigned to property errorCode
     */
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}

